#ifndef ODN_MODELENTITY_H
#define ODN_MODELENTITY_H

//#include <opal\opal.h>
//#include <ogre\Ogre.h>

#include "ODN_DLLAccess.h"
#include "ODN_ModelBit.h"
#include "ODN_BaseEntity.h"
#include "ODN_Events.h"
#include "ODN_Maths.h"
#include "ODN_Containers.h"

namespace ouden {

class ODN_DLLACCESS CModelEntity;



//////////Events///////////

class ODN_DLLACCESS CBreakEvent : public CServerEvent
{
public:
	CBreakEvent(CModelEntity* pEntity) : m_pEntity(pEntity) 		{}
protected:	
	virtual void onActivate();
	virtual void onSend() 		{ /*TODO: Code to encode event data into packet and send over network*/ }
	virtual void onReceive(Packet* pPacket) 	{ /*TODO: Code to decode a network packet into event data*/ }
private:
	CModelEntity* m_pEntity;
};

class ODN_DLLACCESS C_StartMoveEvent : public C_ClientEvent
{
public:
	C_StartMoveEvent(CModelEntity* pEntity, Vector vDirection) : m_pEntity(pEntity), m_vDirection(vDirection) 		{}
protected:	
	virtual void onActivate();
	virtual void onSend() 		{ /*TODO: Code to encode event data into packet and send over network*/ }
	virtual void onReceive(Packet* pPacket) 	{ /*TODO: Code to decode a network packet into event data*/ }
private:
	CModelEntity* m_pEntity;
	Vector m_vDirection;
};

class ODN_DLLACCESS C_EndMoveEvent : public C_ClientEvent
{
public:
	C_EndMoveEvent(CModelEntity* pEntity, Vector vDirection) : m_pEntity(pEntity), m_vDirection(vDirection) 		{}
protected:	
	virtual void onActivate();
	virtual void onSend() 		{ /*TODO: Code to encode event data into packet and send over network*/ }
	virtual void onReceive(Packet* pPacket) 	{ /*TODO: Code to decode a network packet into event data*/ }
private:
	CModelEntity* m_pEntity;
	Vector m_vDirection;
};

//////End of Events////////



class ODN_DLLACCESS CModelEntity : public CBaseEntity
{
	public:
		
		DECLARE_ENTITY_CLASS(CModelEntity);
		
		CModelEntity(String sName);
		virtual ~CModelEntity();
		
		virtual void update() 		{}
		
		void setModel(String sModelName);
		
		void addBit(CModelBit* bit) 		{ m_pBits.push_back(bit); }
		
	protected:
		
		friend class CBreakEvent;
		//TODO: Think about the need for client and server versions of client
		// events and their functions
		friend class C_StartMoveEvent;
		friend class C_EndMoveEvent;
		
		//Event handling functions
		virtual void onBreak() 		{}// = 0;
		virtual void onStartMove(Vector vDirection) 		{}// = 0;
		virtual void onEndMove(Vector vDirection) 		{}// = 0;
		
	private:
		
		Array<CModelBit*> m_pBits;
		
};

} //namespace ouden

#endif // ODN_MODELENTITY_H
